package com.jinzhi.jzweb.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Description TODO
 * @Author YangQiWu
 * @Date 2023/4/19 19:32
 */
public class FileUrlUtil {


    public static String getFileName(String url){
        String substring = "";
        int index = 0;
        if(!url.equals("")){
            int a = url.lastIndexOf("/");
            int b = url.lastIndexOf(".");
            substring = url.substring(a+1, b);
            char[] chars = substring.toCharArray();
            for (int i=0;i<chars.length;i++){
                char aChar = chars[i];
                String value = String.valueOf(aChar);
                if (vd(value)){
                    index = i;
                    break;
                }
            }
        }
        return substring.substring(index);
    }


    //判断是否为汉字
    public static boolean vd(String str) {
        String regEx = "[\u4e00-\u9fa5]";
        Pattern pat = Pattern.compile(regEx);
        Matcher matcher = pat.matcher(str);
        boolean flg = false;
        if (matcher.find())
            flg = true;
        return flg;
    }

}
